import 'nprogress/nprogress.css';

import NProgress from 'nprogress';
import { createRouter, createWebHistory } from 'vue-router';

const routes = [
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/home',
    component: () => import('../pages/home/index.vue'),
  },
  {
    path: '/login',
    component: () => import('../pages/login/index.vue'),
  },
  {
    path: '/user/:id',
    component: () => import('../pages/user/index.vue'),
  },
  {
    path: '/notice/:id',
    component: () => import('../pages/notice/index.vue'),
  },
  {
    path: '/editor',
    component: () => import('../pages/home/editor/index.vue'),
  },
  {
    path: '/live',
    component: () => import('../pages/live/index.vue'),
  },
  {
    path: '/live/detail',
    component: () => import('../pages/live/detail/index.vue'),
  },
  {
    path: '/map',
    component: () => import('../pages/map/index.vue'),
  },
  {
    path: '/test',
    component: () => import('../pages/test/index.vue'),
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

router.beforeEach((to, from, next) => {
  NProgress.start();
  next();
});

router.afterEach(() => {
  NProgress.done();
});

export default router;
